#include <cmath>
#include <iostream>

const double pi = 3.1415926;

class shape {
public:
  virtual void display() { std::cout << "shape" << std::endl; }
};

class circle : public shape {
private:
  double x;
  double y;
  double r;

public:
  circle(double x, double y, double r) : x(x), y(y), r(r){};
  void display() { printf("x = %f, y = %f, z = %f\n", x, y, r); }
  virtual double area() { return r * r * pi; };
};

class rectangle : public shape {
private:
  double x1;
  double y1;
  double x2;
  double y2;

public:
  rectangle(double x1, double y1, double x2, double y2)
      : x1(x1), y1(y1), x2(x2), y2(y2){};
  void display() {
    printf("x1 = %f, y1 = %f, x2 = %f, y2 = %f\n", x1, y1, x2, y2);
  }
  virtual double area() { return fabs((x1 - x2) * (y1 - y2)); };
};

int main() {
  circle c = circle(2, 3, 4);
  std::cout << c.area() << std::endl;
  c.display();
  rectangle r = rectangle(1, 2, 3, 4);
  std::cout << r.area() << std::endl;
  r.display();

  std::cout << "-----------" << std::endl;

  shape *s = &c;
  s->display();
  s = &r;
  s->display();
}